package Demo2;

import java.util.Scanner;

public class Demo19 {
    public static void main(String[] args) {
        Object lock=new Object();

        Thread t1=new Thread(()->{
    try {
        System.out.println("wait之前");
        synchronized (lock){
        lock.wait();
        }
        System.out.println("wait之后");
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
}
        });

        Thread t2=new Thread(()->{
            Scanner scanner=new Scanner(System.in);
            System.out.println("按任意键结束wait等待");
            scanner.next();
            synchronized (lock){
                lock.notify();
            }
        });
t1.start();
t2.start();


    }
}
